<?php
namespace app\libs;

class Sql {
    public static function buildSelectSql($table, $fields, $where, $filterRows, $pageSize) {
        $ret = 'select ' . $fields . ' from ' . $table
        . ' where ' . $where . ' and id <=('
            . 'select id from '. $table
            .' where '. $where
            .' order by id desc limit '. $filterRows .', 1)'
        .' order by id desc limit '. $pageSize;
        
        return $ret;
    }
}